{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <form id="myform" action="{:U('Model/update')}" method="post">
        <div class="form-group row">
            <label class="form-control-label col-md-2"><font color="red">*</font>模型名称</label>
            <div class="col-md-5">
                <input type="text" class="form-control" name="name" value="{$vo.name}" size="20" class="input-text required" minlength="2" title="{:L(module_tip_title)}" />
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2"><font color="red">*</font>模型表名</label>
            <div class="col-md-5">
                <input type="text" class="form-control" name="tablename" disabled="disabled" value="{$vo.tablename}" size="20"/>
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">列表页调用字段</label>
            <div class="col-md-5">
                <input type="text" id="listfields" class="form-control" name="listfields"  class="input-text" size="55" value="{if condition="empty($vo['listfields'])"}*{else /}{$vo.listfields}{/if}" /> {:L(examples)}:id,title,url,catid
            </div>
        </div>
        <div class="form-group row">
            <label class="form-control-label col-md-2">前台搜索模型</label>
            <div class="col-md-5">
                {:Form::radio(array('field'=>'issearch','options'=>array('1'=>L('yes'),'0'=>L('no'))),$vo['issearch'])}
            </div>
        </div>

        <div class="form-group row">
            <label class="form-control-label col-md-2">模型简介</label>
            <div class="col-md-5">
                <textarea id="description" class="form-control" name="description" rows=4"" cols="55">{$vo.description}</textarea>
            </div>
        </div>
        <div class="form-actions">
            <input type="hidden" name="id" value="{$vo.id}">
            <button type="submit" class="btn btn-primary">提交</button>
            <button type="button" class="btn btn-danger" onclick="javascript:history.back(-1);return false;">返回</button>
        </div>
    </form>
</div>
{/block}


{block name="script"}
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });
            } else {
                layer.msg(data.info, {
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        }
    </script>
{/block}